apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: hello-gofunc-filter
spec:
  configPatches:
    - applyTo: EXTENSION_CONFIG
      patch:
        operation: ADD
        value:
          name: my-wasm-extension
          typed_config:
            '@type': type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
            config:
              configuration:
                '@type': type.googleapis.com/google.protobuf.StringValue
                value: |
                  {}
              root_id: my-wasm-root-id
              vm_config:
                code:
                  local:
                    filename: /etc/wasm-filters/main.wasm
                runtime: envoy.wasm.runtime.v8
                vm_id: my-wasm-vm-id
    - applyTo: HTTP_FILTER
      match:
        listener:
          filterChain:
            filter:
              name: envoy.filters.network.http_connection_manager
              subFilter:
                name: envoy.filters.http.router
      patch:
        operation: INSERT_BEFORE
        value:
          config_discovery:
            config_source:
              ads: {}
            type_urls:
              - type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
          name: my-wasm-extension
  workloadSelector:
    labels:
      app: main-service
